package com.example.demo.advice;

import lombok.extern.java.Log;
import lombok.extern.log4j.Log4j;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @program: SpringAOP
 * @ClassName MyAdvice
 * @description:
 * @author: zsn
 * @create: 2023-08-08 19:46
 * @Version 1.0
 **/
@Component
@Aspect
@Slf4j
public class MyAdvice {

    @Pointcut("execution(void com.example.demo.service.BookServiceImpl.*())")
    public void pt(){}
    @Before("pt()")
//    public void method(){
//        log.info("方法开始执行");
//    }
//
//    @After("pt()")
//    public void method2(){
//        log.info("方法执行结束");
//    };
//

    @Around("pt()")
    public void around(ProceedingJoinPoint pjp) throws Throwable {
        log.info("方法开始执行");
        pjp.proceed();
        log.info("方法执行结束");
    }
}